package main

import (
	"github.com/aceld/zinx/ziface"
	"github.com/aceld/zinx/znet"
	"time"
	"zinx_game/api"
	"zinx_game/bootstrap"
	"zinx_game/core/conn_manager"
)

func main() {
	bootstrap.Init()
	s := znet.NewServer()
	//注册路由
	addRoute(s)
	//心跳检测
	s.StartHeartBeatWithOption(3*time.Second, &ziface.HeartBeatOption{
		OnRemoteNotAlive: conn_manager.MyOnRemoteNotAlive,
	})
	//连接成功后的处理
	s.SetOnConnStart(conn_manager.MyStart)
	//客户端断开后的处理
	s.SetOnConnStop(conn_manager.MyStop)
	//// 启动服务器
	s.Serve()
}

func addRoute(s ziface.IServer) {
	s.AddRouter(1, &api.PlayerApi{})
}
